/*
 * @Author: YMJ
 * @Date: 2020-10-30 10:27:42
 */
import Vue from 'vue'
import Router from 'vue-router'
// import addDynamicMenuAndRoutes from '@/utils/setRoute'
Vue.use(Router)

/* Layout */
import Layout from '@/layout'
// import addDynamicRoutes from '@/utils/setRoute'
// import member from './modules/member.js'
// import organize from './modules/organize.js'
// import operate from './modules/operate.js'
// import commodity from './modules/commodity.js'
// import news from './modules/news.js'
// import report from './modules/report.js'
// import opinion from './modules/opinion.js'
// import basics from './modules/basics.js'
// import system from './modules/system.js'

/* Router Modules */

export const constantRoutes = [
  {
    path: '/login',
    component: () => import('@/views/login/index'),
    hidden: true
  },
  {
    path: '/404',
    component: () => import('@/views/error/404'),
    hidden: true
  },
  {
    path: '/',
    component: Layout,
    redirect: '/dashboard',
    children: [
      {
        path: 'dashboard',
        component: () => import('@/views/dashboard/index'),
        name: 'Dashboard',
        meta: { title: '首页', icon: 'dashboard', affix: true }
      },
      {
        path: 'password',
        component: () => import('@/views/password'),
        name: 'Password',
        hidden: true,
        meta: { title: '修改密码', affix: false }
      },
      {
        path: 'Profile',
        component: () => import('@/views/member/MemberInfo/Proflie.vue'),
        name: 'Profile',
        hidden: true,
        meta: { title: '会员详情', affix: false }
      },
      // 举报管理
      {
        path: 'management',
        component: () => import('@/views/report/Management.vue'),
        name: 'management',
        hidden: true,
        meta: { title: '举报管理', affix: false }
      },
       // 申诉管理
       {
        path: 'appeal',
        component: () => import('@/views/report/Appeal.vue'),
        name: 'management',
        hidden: true,
        meta: { title: '申诉管理', affix: false }
      },
      // 添加会员标签
      {
        path: 'setTag/label',
        component: () => import('@/views/member/MemberInfo/Label.vue'),
        name: 'label',
        hidden: true,
        meta: { title: '添加会员标签', affix: false }
      },
    ]
  }

]

/**
 * asyncRoutes
 * the routes that need to be dynamically loaded based on user roles
 */
export const asyncRoutes = [

]

const createRouter = () => new Router({
  scrollBehavior: () => ({ y: 0 }),
  routes: constantRoutes
})

const router = createRouter()

export function resetRouter() {
  const newRouter = createRouter()
  router.matcher = newRouter.matcher // reset router
}
export default router
